package com.example.administrator.daydayappmarket.game.fragment.fragments.toplist.fragment;


import android.os.Bundle;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.example.administrator.daydayappmarket.R;
import com.example.administrator.daydayappmarket.game.fragment.common.CommonFragmentAdapter;
import com.example.administrator.daydayappmarket.game.fragment.fragments.toplist.fragment.fragments.online.GameTopListOnlineFragment;
import com.example.administrator.daydayappmarket.game.fragment.fragments.toplist.fragment.fragments.single.GameTopListSingleFragment;

import java.util.ArrayList;
import java.util.List;

import butterknife.ButterKnife;
import butterknife.InjectView;

/**
 * A simple {@link Fragment} subclass.
 */
public class GameTopListFragment extends Fragment {

    private List<Fragment> fragments;

    private List<String> titles;


    @InjectView(R.id.fragment_game_topList_tabLayout)
    TabLayout mFragmentGameTopListTabLayout;
    @InjectView(R.id.fragment_game_topList_viewPager)
    ViewPager mFragmentGameTopListViewPager;

    public GameTopListFragment() {
        // Required empty public constructor
    }


    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.fragment_game_top_list, container, false);
        ButterKnife.inject(this, view);

        fragments=new ArrayList<>();
        fragments.add(new GameTopListSingleFragment());
        fragments.add(new GameTopListOnlineFragment());


        titles=new ArrayList<>();
        titles.add("单机榜");
        titles.add("网游榜");

        CommonFragmentAdapter adapter=new CommonFragmentAdapter(getChildFragmentManager(),fragments,titles);

        mFragmentGameTopListViewPager.setAdapter(adapter);

        mFragmentGameTopListTabLayout.setupWithViewPager(mFragmentGameTopListViewPager);


        return view;
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.reset(this);
    }
}
